package Library;

public class Book implements Comparable{
	//为了实现ArrayList的自定义排序，需要Book类实现Comparable接口，重写compareTo(To)方法
	private Integer id;//编号有且只有一个
	private String name;//名字，可重名
	private String author;//作者
	private String press;//出版社
	private String description;//类别
	private String state;//状态
	
	public Book(Integer id,String name,String author,String press,String description) {
		this.id=id;
		this.name=name;
		this.author=author;
		this.press=press;
		this.description=description;
		this.state="可借阅";//初始状态都为可借阅
	}
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getAuthor() {
		return author;
	}
	public void setAuthor(String author) {
		this.author = author;
	}
	public String getPress() {
		return press;
	}
	public void setPress(String press) {
		this.press = press;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}

	
	@Override
	public String toString() {
		return "Book [id:" + id + ", name:" + name + ", author:" + author + ", press:" + press + ", description:"
				+ description + ", state:" + state + "]";
	}

	@Override
	public int compareTo(Object o) {
		// TODO Auto-generated method stub
		 Book s = (Book) o;
	        if (this.id>s.id) {
	            return 1;
	        }
	        else{
	            return -1;
	        }

	}
	

}
